package hlhj.fhp.newslib.activitys

import android.support.v4.view.ViewPager
import hlhj.fhp.newslib.BaseAty
import hlhj.fhp.newslib.R
import hlhj.fhp.newslib.adapters.ImgPagerAdp
import hlhj.fhp.newslib.network.Apis
import kotlinx.android.synthetic.main.aty_image_info.*
import java.util.ArrayList

/**
 * Created by Administrator on 2018\6\13 0013.
 */
class ImageInfoAty:BaseAty(), ViewPager.OnPageChangeListener {
    private val imgs=ArrayList<String>()
    private var tittle=""
    private var content=""
    private lateinit var pagerAdp:ImgPagerAdp
    override fun initListener() {
        viewPager.addOnPageChangeListener(this)
        btExit.setOnClickListener {
            finish()
        }
    }

    override fun initView() {
        /*接收数据*/
        imgs.addAll(intent.getStringArrayListExtra("imgs"))
        tvTittle.text=intent.getStringExtra("tittle")
        tvContent.text=intent.getStringExtra("content")
        tvAll.text=imgs.size.toString()

        /**/
        pagerAdp=ImgPagerAdp(imgs,this)

        viewPager.adapter=pagerAdp

        Apis.getInfoDetail(intent.getIntExtra("id",0))
                .doOnSubscribe {

                }
                .subscribe {

                }

    }

    override fun onPageScrollStateChanged(state: Int) {
    }

    override fun onPageScrolled(position: Int, positionOffset: Float, positionOffsetPixels: Int) {
    }

    override fun onPageSelected(position: Int) {
        tvCurrent.text= (position+1).toString()

    }

    override fun getContentId(): Int {
        return R.layout.aty_image_info
    }
}